home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
PRG
/
Depth lib 1.0 folder.sit
/
Depth lib 1.0 folder
/
depth_lib 1.0 ƒ
/
Shell.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-12-06
|
5KB
|
241 lines
/********************************************************************************
PROJECT: clut_fade.ケ
FILE: shell.c
PURPOSE: 'clut' fading functions
STATUS: Public Domain Demo.
********************************************************************************/
//================================= INCLUDES ====================================
#include "shell.h"
#include "depth.h"
// dialog items
#define kMillions 2
#define kThousands 3
#define k256 4
#define k16 5
#define k4 6
#define k2 7
#define kColor 8
#define kGray 9
//================================= FUNCTIONS ===================================
void init_toolbox(void);
void test_window(void);
void SetRadioItem(DialogPtr dlog, short itemNum, Boolean on);
void DisableDItem(DialogPtr dlog, short itemNum);
/*********************************** main ***************************************/
extern
void main(void)
{
init_toolbox();
test_window();
}
/*** main ***/
/********************************** init_toolbox ********************************/
static
void init_toolbox(void)
{
MaxApplZone();
MoreMasters();
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(0);
InitCursor();
FlushEvents(everyEvent, 0);
DrawMenuBar();
}
/*** init_toolbox ***/
static
void SetRadioItem(DialogPtr dlog, short itemNum, Boolean on)
{
short iType;
Handle iHandle;
Rect iRect;
GetDItem(dlog,itemNum,&iType,&iHandle,&iRect);
SetCtlValue((ControlHandle)iHandle,on ? 1 : 0);
}
static
void DisableDItem(DialogPtr dlog, short itemNum)
{
short iType;
Handle iHandle;
Rect iRect;
GetDItem(dlog,itemNum,&iType,&iHandle,&iRect);
HiliteControl((ControlHandle)iHandle,255);
}
/********************************** test_window *********************************/
static
void test_window(void)
{
DialogPtr d;
GrafPtr g;
short hit;
GDHandle hGD;
CTabHandle hCTab;
ControlHandle theCtl;
Rect r;
short depthItem;
short newDepthItem;
short newDepth;
short modeItem;
short newModeItem;
short newMode;
if (d = GetNewDialog(128, nil, (WindowPtr) -1L))
{
GetPort(&g);
SetPort(d);
// find the maximum depth of main monitor, and disable radio items.
switch (MaxScreenDepth(GetMainDevice()))
{
case k2Colors:
DisableDItem(d,k4);
case k4Colors:
DisableDItem(d,k16);
case k16Colors:
DisableDItem(d,k256);
case k256Colors:
DisableDItem(d,kThousands);
case kThousandsColors:
DisableDItem(d,kMillions);
case kMillionsColors:
break;
}
// get the current depth and set the appropriate radio item.
switch(GetScreenDepth(GetMainDevice()))
{
case k2Colors:
depthItem = k2;
break;
case k4Colors:
depthItem = k4;
break;
case k16Colors:
depthItem = k16;
break;
case k256Colors:
depthItem = k256;
break;
case kThousandsColors:
depthItem = kThousands;
break;
case kMillionsColors:
depthItem = kMillions;
break;
}
SetRadioItem(d,depthItem,TRUE);
// figure out which modes are supported and disable radio items
if (!SupportsMode(GetMainDevice(),kColorMode))
DisableDItem(d,kColor);
if (!SupportsMode(GetMainDevice(),kGrayMode))
DisableDItem(d,kGray);
// get current mode and set appropriate radio item
switch(GetScreenMode(GetMainDevice()))
{
case kGrayMode:
modeItem = kGray;
break;
case kColorMode:
modeItem = kColor;
break;
}
SetRadioItem(d,modeItem,TRUE);
ShowWindow(d);
do
{
ModalDialog(nil, &hit);
switch (hit)
{
// the depth will be changed
case k2:
newDepthItem = k2;
newDepth = k2Colors;
goto changeDepth;
case k4:
newDepthItem = k4;
newDepth = k4Colors;
goto changeDepth;
case k16:
newDepthItem = k16;
newDepth = k16Colors;
goto changeDepth;
case k256:
newDepthItem = k256;
newDepth = k256Colors;
goto changeDepth;
case kThousands:
newDepthItem = kThousands;
newDepth = kThousandsColors;
goto changeDepth;
case kMillions:
newDepthItem = kMillions;
newDepth = kMillionsColors;
changeDepth: SetRadioItem(d,depthItem,FALSE);
depthItem = newDepthItem;
SetRadioItem(d,depthItem,TRUE);
SetScreenDepth(GetMainDevice(),newDepth);
break;
// the mode will be changed
case kGray:
newModeItem = kGray;
newMode = kGrayMode;
goto changeMode;
case kColor:
newModeItem = kColor;
newMode = kColorMode;
changeMode: SetRadioItem(d,modeItem,FALSE);
modeItem = newModeItem;
SetRadioItem(d,modeItem,TRUE);
SetScreenMode(GetMainDevice(),newMode);
break;
default:
break;
}
}
while (hit != 1);
SetPort(g);
DisposDialog(d);
}
}
/*** test_window ***/
//===================================== EOF =====================================